package Gui;

import java.awt.Container;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.border.TitledBorder;
import java.awt.List;
import javax.swing.UIManager;
import javax.swing.JRadioButton;

import Ctr.CtrCustomer;
import Ctr.CtrProduct;
import Ctr.CtrSalesorder;
import Ctr.CtrSupplier;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.SwingConstants;

public class GUI extends JFrame {

	private final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
	private JTextField txtSaleSearch;
	private JTextField txtCustomerSearch;
	private JTextField txtCreateCustomerName;
	private JTextField txtCreateCustomerAddress;
	private JTextField txtCreateCustomerZip;
	private JTextField txtCreateCustomerCity;
	private JTextField txtCreateCustomerPhone;
	private JTextField txtUpdateCustomerName;
	private JTextField txtUpdateCustomerAddress;
	private JTextField txtUpdateCustomerZip;
	private JTextField txtUpdateCustomerCity;
	private JTextField txtUpdateCustomerPhone;
	private JTextField txtSupID;
	private JTextField txtUpdateSupName;
	private JTextField txtUpdateSupAddress;
	private JTextField txtUpdateSupCountry;
	private JTextField txtUpdateSupEmail;
	private JTextField txtUpdateSupPhone;
	private JTextField txtCreateSupName;
	private JTextField txtCreateSupAddress;
	private JTextField txtCreateSupCountry;
	private JTextField txtCreateSupEmail;
	private JTextField txtCreateSupPhone;
	private JTextField txtProSearch;
	private JTextField txtProName;
	private JTextField txtProPurchPrice;
	private JTextField txtProSalesPrice;
	private JTextField txtCountry;
	private JTextField txtMinStock;
	private JTextField txtClothSize;
	private JTextField txtClothColor;
	private JTextField txtEquipType;
	private JTextField txtEquipDescription;
	private JTextField txtGunFabric;
	private JTextField txtGunCalibre;
	private String SavedSupp;
	private String SavedSup;
	private List listSearch;
	private List listSaleOrder;
	private String savedPro;
	private List listcustSearch;
	private String savedCustID;
	private String savedCustID2;
	private JTextField textField;

	/**
	 * Create the application.
	 */
	public GUI() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		setBounds(100, 100, 748, 422);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		getContentPane().setLayout(null);
		tabbedPane.setBounds(0, 0, 732, 383);
		getContentPane().add(tabbedPane);
		
		JPanel panel = new JPanel();
		tabbedPane.addTab("Sale", null, panel, null);
		panel.setLayout(null);
		
		JPanel panel_4 = new JPanel();
		panel_4.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Search for wares", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_4.setBounds(10, 11, 272, 333);
		panel.add(panel_4);
		panel_4.setLayout(null);
		
		txtSaleSearch = new JTextField();
		txtSaleSearch.setColumns(10);
		txtSaleSearch.setBounds(68, 20, 177, 20);
		panel_4.add(txtSaleSearch);
		
		final List listSearch = new List();
		listSearch.setBounds(10, 105, 252, 111);
		panel_4.add(listSearch);
		
		JButton btnSaleSearch = new JButton("Search");
		btnSaleSearch.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				CtrProduct ctrp = new CtrProduct();
				if(listSearch != null)
				{
					listSearch.removeAll();
				}
				listSearch.add("ID: " + ctrp.findProduct(txtSaleSearch.getText()).getProductID() + ", Name " + ctrp.findProduct(txtSaleSearch.getText()).getName() + ", PurchasePrice " + ctrp.findProduct(txtSaleSearch.getText()).getPurchasePrice() + ", SalesPrice " + ctrp.findProduct(txtSaleSearch.getText()).getSalesPrice() + ", Country " + ctrp.findProduct(txtSaleSearch.getText()).getCountryOfOrigin() + ", Stock " + ctrp.findProduct(txtSaleSearch.getText()).getStock() + ", MinStock " + ctrp.findProduct(txtSaleSearch.getText()).getMinStock()); 		
				savedPro = txtSaleSearch.getText();
			}
		});
		btnSaleSearch.setBounds(156, 51, 89, 23);
		panel_4.add(btnSaleSearch);
		
		JLabel lblId_2 = new JLabel("ID:");
		lblId_2.setBounds(10, 26, 46, 14);
		panel_4.add(lblId_2);
		
		JPanel panel_6 = new JPanel();
		panel_6.setBorder(new TitledBorder(null, "Order", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_6.setBounds(292, 11, 425, 333);
		panel.add(panel_6);
		panel_6.setLayout(null);
		
		final List listSaleOrder = new List();
		listSaleOrder.setBounds(10, 22, 405, 263);
		panel_6.add(listSaleOrder);
		
		textField = new JTextField();
		textField.setText("1");
		textField.setBounds(10, 239, 96, 20);
		panel_4.add(textField);
		textField.setColumns(10);
		
		JButton btnProToSale = new JButton("Add Selected to Order");
		btnProToSale.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				listSaleOrder.add(listSearch.getSelectedItem());
				listSearch.removeAll();
				textField.setText("1");
			}
		});
		btnProToSale.setBounds(91, 270, 171, 23);
		panel_4.add(btnProToSale);
		
		JLabel lblSearchResults_1 = new JLabel("Search results");
		lblSearchResults_1.setBounds(10, 85, 95, 14);
		panel_4.add(lblSearchResults_1);
		
		JLabel lblAntal = new JLabel("Antal");
		lblAntal.setBounds(10, 222, 72, 14);
		panel_4.add(lblAntal);
		
		JButton btnNewButton = new JButton("Get Selected ware info");
		btnNewButton.setBounds(91, 299, 171, 23);
		panel_4.add(btnNewButton);
		
		JButton btnPrint = new JButton("Print");
		btnPrint.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
			}
		});
		btnPrint.setBounds(326, 291, 89, 23);
		panel_6.add(btnPrint);
		
		JButton btnDeleteFromOrder = new JButton("Delete From Order");
		btnDeleteFromOrder.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				listSaleOrder.remove(listSaleOrder.getSelectedItem());
			}
		});
		btnDeleteFromOrder.setBounds(163, 291, 153, 23);
		panel_6.add(btnDeleteFromOrder);
		
		JButton btnDeleteOrder = new JButton("Delete Order");
		btnDeleteOrder.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				listSaleOrder.removeAll();
			}
		});
		btnDeleteOrder.setBounds(10, 291, 126, 23);
		panel_6.add(btnDeleteOrder);
		
		JPanel panel_1 = new JPanel();
		tabbedPane.addTab("Customer", null, panel_1, null);
		panel_1.setLayout(null);
		
		JPanel panel_7 = new JPanel();
		panel_7.setBorder(new TitledBorder(null, "Search for Customer", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_7.setBounds(10, 11, 232, 333);
		panel_1.add(panel_7);
		panel_7.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("ID:");
		lblNewLabel.setBounds(10, 22, 46, 14);
		panel_7.add(lblNewLabel);
		
		txtCustomerSearch = new JTextField();
		txtCustomerSearch.setBounds(66, 19, 156, 20);
		panel_7.add(txtCustomerSearch);
		txtCustomerSearch.setColumns(10);
		
		final List listCustomerSearch = new List();
		listCustomerSearch.setBounds(10, 115, 212, 133);
		panel_7.add(listCustomerSearch);
		
		JButton btnCustomerSearch = new JButton("Search");
		btnCustomerSearch.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				listCustomerSearch.removeAll();
				CtrCustomer ctrc = new CtrCustomer();
				listCustomerSearch.add("ID: " + ctrc.getCustomer(txtCustomerSearch.getText()).getId() + ", Name: " + ctrc.getCustomer(txtCustomerSearch.getText()).getName() + 
						", Address: " + ctrc.getCustomer(txtCustomerSearch.getText()).getAddress() + ", Zip: " + ctrc.getCustomer(txtCustomerSearch.getText()).getZipCode() + 
						", City: " + ctrc.getCustomer(txtCustomerSearch.getText()).getCity() + ", PhoneNo: " + ctrc.getCustomer(txtCustomerSearch.getText()).getPhoneNo());
				savedCustID = txtCustomerSearch.getText();
			}
		});
		btnCustomerSearch.setBounds(133, 50, 89, 23);
		panel_7.add(btnCustomerSearch);
		
		final JLabel lblSearchCust = new JLabel("");
		lblSearchCust.setHorizontalAlignment(SwingConstants.CENTER);
		lblSearchCust.setBounds(10, 288, 212, 14);
		panel_7.add(lblSearchCust);
		
		JButton btnCustDel = new JButton("Delete");
		btnCustDel.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				CtrCustomer ctrc = new CtrCustomer();
				ctrc.deleteCustomer(savedCustID);
				listCustomerSearch.removeAll();
			}
		});
		btnCustDel.setBounds(10, 254, 89, 23);
		panel_7.add(btnCustDel);
		
		JButton btnCustSel = new JButton("Select");
		btnCustSel.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				if(savedCustID != null && !savedCustID.isEmpty())
				{
					CtrCustomer ctrc = new CtrCustomer();
					txtUpdateCustomerName.setText(ctrc.getCustomer(savedCustID).getName());
					txtUpdateCustomerAddress.setText(ctrc.getCustomer(savedCustID).getAddress());
					txtUpdateCustomerZip.setText(ctrc.getCustomer(savedCustID).getZipCode());
					txtUpdateCustomerPhone.setText(ctrc.getCustomer(savedCustID).getPhoneNo());
					txtUpdateCustomerCity.setText(ctrc.getCustomer(savedCustID).getCity());
					savedCustID2 = ctrc.getCustomer(savedCustID).getId();
					lblSearchCust.setText("Customer selected");
				}					
			}
				
		});
		btnCustSel.setBounds(133, 254, 89, 23);
		panel_7.add(btnCustSel);
		
		JLabel label_6 = new JLabel("Search Results");
		label_6.setBounds(10, 95, 124, 14);
		panel_7.add(label_6);
		
		JPanel panel_8 = new JPanel();
		panel_8.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Create Customer", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_8.setBounds(485, 11, 232, 333);
		panel_1.add(panel_8);
		panel_8.setLayout(null);
		
		JLabel lblName = new JLabel("Name");
		lblName.setBounds(10, 24, 79, 14);
		panel_8.add(lblName);
		
		JLabel lblNewLabel_1 = new JLabel("Address");
		lblNewLabel_1.setBounds(10, 52, 79, 14);
		panel_8.add(lblNewLabel_1);
		
		JLabel lblNewLabel_2 = new JLabel("Zipcode");
		lblNewLabel_2.setBounds(10, 80, 79, 14);
		panel_8.add(lblNewLabel_2);
		
		JLabel lblNewLabel_3 = new JLabel("City");
		lblNewLabel_3.setBounds(10, 108, 57, 14);
		panel_8.add(lblNewLabel_3);
		
		JLabel lblNewLabel_4 = new JLabel("Phone number");
		lblNewLabel_4.setBounds(10, 136, 93, 14);
		panel_8.add(lblNewLabel_4);
		
		txtCreateCustomerName = new JTextField();
		txtCreateCustomerName.setBounds(136, 21, 86, 20);
		panel_8.add(txtCreateCustomerName);
		txtCreateCustomerName.setColumns(10);
		
		txtCreateCustomerAddress = new JTextField();
		txtCreateCustomerAddress.setBounds(136, 49, 86, 20);
		panel_8.add(txtCreateCustomerAddress);
		txtCreateCustomerAddress.setColumns(10);
		
		txtCreateCustomerZip = new JTextField();
		txtCreateCustomerZip.setBounds(136, 77, 86, 20);
		panel_8.add(txtCreateCustomerZip);
		txtCreateCustomerZip.setColumns(10);
		
		txtCreateCustomerCity = new JTextField();
		txtCreateCustomerCity.setBounds(136, 105, 86, 20);
		panel_8.add(txtCreateCustomerCity);
		txtCreateCustomerCity.setColumns(10);
		
		txtCreateCustomerPhone = new JTextField();
		txtCreateCustomerPhone.setBounds(136, 133, 86, 20);
		panel_8.add(txtCreateCustomerPhone);
		txtCreateCustomerPhone.setColumns(10);
		
		JRadioButton rdbtnPrivate = new JRadioButton("Private");
		rdbtnPrivate.setBounds(10, 160, 109, 23);
		panel_8.add(rdbtnPrivate);
		
		JRadioButton rdbtnBuiness = new JRadioButton("Business");
		rdbtnBuiness.setBounds(121, 160, 109, 23);
		panel_8.add(rdbtnBuiness);
		
		final JLabel lblCreateCust = new JLabel("");
		lblCreateCust.setHorizontalAlignment(SwingConstants.CENTER);
		lblCreateCust.setBounds(10, 274, 212, 14);
		panel_8.add(lblCreateCust);
		
		JButton btnNewButton_1 = new JButton("Create");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				CtrCustomer ctrc = new CtrCustomer();
				if(txtCreateCustomerName.getText() != null && !txtCreateCustomerName.getText().isEmpty())
				{
					if(txtCreateCustomerCity.getText() != null && !txtCreateCustomerCity.getText().isEmpty())
					{
						if(txtCreateCustomerAddress.getText() != null && !txtCreateCustomerAddress.getText().isEmpty())
						{
							if(txtCreateCustomerPhone.getText() != null && !txtCreateCustomerPhone.getText().isEmpty())
							{
								if(txtCreateCustomerZip.getText() != null && !txtCreateCustomerZip.getText().isEmpty())
								{
									ctrc.addCustomer(txtCreateCustomerName.getText(), txtCreateCustomerAddress.getText(), txtCreateCustomerZip.getText(), 
											txtCreateCustomerCity.getText(), txtCreateCustomerPhone.getText());
									lblCreateCust.setText("Customer Created");
								}
							}
						}
					}
				}	
			}
		});
		btnNewButton_1.setBounds(133, 299, 89, 23);
		panel_8.add(btnNewButton_1);
		

		
		JPanel panel_10 = new JPanel();
		panel_10.setLayout(null);
		panel_10.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Update Customer", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_10.setBounds(243, 11, 232, 333);
		panel_1.add(panel_10);
		
		JLabel label_1 = new JLabel("Name");
		label_1.setBounds(10, 24, 79, 14);
		panel_10.add(label_1);
		
		JLabel label_2 = new JLabel("Address");
		label_2.setBounds(10, 52, 79, 14);
		panel_10.add(label_2);
		
		JLabel label_3 = new JLabel("Zipcode");
		label_3.setBounds(10, 80, 79, 14);
		panel_10.add(label_3);
		
		JLabel label_4 = new JLabel("City");
		label_4.setBounds(10, 108, 57, 14);
		panel_10.add(label_4);
		
		JLabel label_5 = new JLabel("Phone number");
		label_5.setBounds(10, 136, 93, 14);
		panel_10.add(label_5);
		
		txtUpdateCustomerName = new JTextField();
		txtUpdateCustomerName.setColumns(10);
		txtUpdateCustomerName.setBounds(136, 21, 86, 20);
		panel_10.add(txtUpdateCustomerName);
		
		txtUpdateCustomerAddress = new JTextField();
		txtUpdateCustomerAddress.setColumns(10);
		txtUpdateCustomerAddress.setBounds(136, 49, 86, 20);
		panel_10.add(txtUpdateCustomerAddress);
		
		txtUpdateCustomerZip = new JTextField();
		txtUpdateCustomerZip.setColumns(10);
		txtUpdateCustomerZip.setBounds(136, 77, 86, 20);
		panel_10.add(txtUpdateCustomerZip);
		
		txtUpdateCustomerCity = new JTextField();
		txtUpdateCustomerCity.setColumns(10);
		txtUpdateCustomerCity.setBounds(136, 105, 86, 20);
		panel_10.add(txtUpdateCustomerCity);
		
		txtUpdateCustomerPhone = new JTextField();
		txtUpdateCustomerPhone.setColumns(10);
		txtUpdateCustomerPhone.setBounds(136, 133, 86, 20);
		panel_10.add(txtUpdateCustomerPhone);
		
		final JLabel lblUpdateCust = new JLabel("");
		lblUpdateCust.setHorizontalAlignment(SwingConstants.CENTER);
		lblUpdateCust.setBounds(10, 274, 212, 14);
		panel_10.add(lblUpdateCust);
		
		JButton btnCustomerUpdate = new JButton("Update");
		btnCustomerUpdate.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				CtrCustomer ctrc = new CtrCustomer();
				if(txtUpdateCustomerName.getText() != null && !txtUpdateCustomerName.getText().isEmpty())
				{
					if(txtUpdateCustomerCity.getText() != null && !txtUpdateCustomerCity.getText().isEmpty())
					{
						if(txtUpdateCustomerAddress.getText() != null && !txtUpdateCustomerAddress.getText().isEmpty())
						{
							if(txtUpdateCustomerPhone.getText() != null && !txtUpdateCustomerPhone.getText().isEmpty())
							{
								if(txtUpdateCustomerZip.getText() != null && !txtUpdateCustomerZip.getText().isEmpty())
								{
									ctrc.updateCustomer(savedCustID2, txtUpdateCustomerName.getText(), txtUpdateCustomerAddress.getText(), txtUpdateCustomerZip.getText()
											, txtUpdateCustomerCity.getText(), txtUpdateCustomerPhone.getText()); 
									lblUpdateCust.setText("Customer Updated");
								}
							}
						}
					}
				}	
			}
		});
		btnCustomerUpdate.setBounds(133, 299, 89, 23);
		panel_10.add(btnCustomerUpdate);
		

		for(int i = 0; i < 13; i++)
		{
		//	listCustomerSearch.add("Test Customer " + i);
		}
		
		JPanel panel_2 = new JPanel();
		tabbedPane.addTab("Supplier", null, panel_2, null);
		panel_2.setLayout(null);
		
		JPanel panel_11 = new JPanel();
		panel_11.setLayout(null);
		panel_11.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Search for Supplier", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_11.setBounds(10, 11, 232, 333);
		panel_2.add(panel_11);
		
		final List listSupplierSearch = new List();
		listSupplierSearch.setBounds(10, 114, 212, 149);
		panel_11.add(listSupplierSearch);
		
		JLabel lblId = new JLabel("ID:");
		lblId.setBounds(10, 22, 46, 14);
		panel_11.add(lblId);
		
		txtSupID = new JTextField();
		txtSupID.setColumns(10);
		txtSupID.setBounds(66, 19, 156, 20);
		panel_11.add(txtSupID);
		
		JButton btnSupSearch = new JButton("Search");
		btnSupSearch.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				CtrSupplier supp = new CtrSupplier();
				listSupplierSearch.removeAll();
				listSupplierSearch.add("Name: " + supp.findSupplier(txtSupID.getText()).getName() + ", Phone " + supp.findSupplier(txtSupID.getText()).getPhoneNum()); 
				SavedSupp = txtSupID.getText();
			}
		});
		btnSupSearch.setBounds(133, 50, 89, 23);
		panel_11.add(btnSupSearch);
		
		final JLabel lblDeleteSup = new JLabel("");
		lblDeleteSup.setHorizontalAlignment(SwingConstants.CENTER);
		lblDeleteSup.setBounds(10, 303, 212, 14);
		panel_11.add(lblDeleteSup);
		
		JButton button = new JButton("Delete");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				CtrSupplier supp = new CtrSupplier();
				
				if(SavedSupp != null && !SavedSupp.isEmpty())
				{
					supp.deleteSupplier(SavedSupp);
					lblDeleteSup.setText("Supplier Deleted");
					listSupplierSearch.removeAll();
				}
				else
				{
					lblDeleteSup.setText("Supplier not deleted, Search first");
				}
			}
		});
		button.setBounds(20, 269, 89, 23);
		panel_11.add(button);
		
		JLabel lblSearchResults = new JLabel("Search Results");
		lblSearchResults.setBounds(10, 94, 124, 14);
		panel_11.add(lblSearchResults);
		for(int i = 0; i < 11; i++)
		{
			listSupplierSearch.add("Test Supplies " +i);
		}
		
		JPanel panel_13 = new JPanel();
		panel_13.setLayout(null);
		panel_13.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Update Supplier", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_13.setBounds(243, 11, 232, 333);
		panel_2.add(panel_13);
		
		JLabel label_7 = new JLabel("Name");
		label_7.setBounds(10, 24, 79, 14);
		panel_13.add(label_7);
		
		JLabel label_8 = new JLabel("Address");
		label_8.setBounds(10, 52, 79, 14);
		panel_13.add(label_8);
		
		JLabel lblCountry = new JLabel("Country");
		lblCountry.setBounds(10, 80, 79, 14);
		panel_13.add(lblCountry);
		
		JLabel lblEmail = new JLabel("Email");
		lblEmail.setBounds(10, 108, 57, 14);
		panel_13.add(lblEmail);
		
		JLabel label_11 = new JLabel("Phone number");
		label_11.setBounds(10, 136, 93, 14);
		panel_13.add(label_11);
		
		txtUpdateSupName = new JTextField();
		txtUpdateSupName.setColumns(10);
		txtUpdateSupName.setBounds(136, 21, 86, 20);
		panel_13.add(txtUpdateSupName);
		
		txtUpdateSupAddress = new JTextField();
		txtUpdateSupAddress.setColumns(10);
		txtUpdateSupAddress.setBounds(136, 49, 86, 20);
		panel_13.add(txtUpdateSupAddress);
		
		txtUpdateSupCountry = new JTextField();
		txtUpdateSupCountry.setColumns(10);
		txtUpdateSupCountry.setBounds(136, 77, 86, 20);
		panel_13.add(txtUpdateSupCountry);
		
		txtUpdateSupEmail = new JTextField();
		txtUpdateSupEmail.setColumns(10);
		txtUpdateSupEmail.setBounds(136, 105, 86, 20);
		panel_13.add(txtUpdateSupEmail);
		
		txtUpdateSupPhone = new JTextField();
		txtUpdateSupPhone.setColumns(10);
		txtUpdateSupPhone.setBounds(136, 133, 86, 20);
		panel_13.add(txtUpdateSupPhone);
		
		JButton button_1 = new JButton("Select");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				if(SavedSupp != null && !SavedSupp.isEmpty())
				{
					CtrSupplier supp = new CtrSupplier();
					txtUpdateSupName.setText(supp.findSupplier(SavedSupp).getName());
					txtUpdateSupAddress.setText(supp.findSupplier(SavedSupp).getAddress());
					txtUpdateSupCountry.setText(supp.findSupplier(SavedSupp).getCountry());
					txtUpdateSupEmail.setText(supp.findSupplier(SavedSupp).getEmail());
					txtUpdateSupPhone.setText(supp.findSupplier(SavedSupp).getPhoneNum());
					txtUpdateSupPhone.setEditable(false);
					SavedSup = supp.findSupplier(SavedSupp).getSupplierID();
				}
					
			}
		});
		button_1.setBounds(119, 269, 89, 23);
		panel_11.add(button_1);
		
		JButton btnUpdateSup = new JButton("Update");
		btnUpdateSup.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				CtrSupplier supp = new CtrSupplier();
				supp.updateSupplier(supp.findSupplier(SavedSup).getSupplierID(), txtUpdateSupName.getText(), txtUpdateSupAddress.getText(), 
						txtUpdateSupCountry.getText(), txtUpdateSupPhone.getText(), txtUpdateSupEmail.getText());
			}
		});
		btnUpdateSup.setBounds(133, 299, 89, 23);
		panel_13.add(btnUpdateSup);
		
		JPanel panel_14 = new JPanel();
		panel_14.setLayout(null);
		panel_14.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Create Supplier", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_14.setBounds(485, 11, 232, 333);
		panel_2.add(panel_14);
		
		JLabel label_12 = new JLabel("Name");
		label_12.setBounds(10, 24, 79, 14);
		panel_14.add(label_12);
		
		JLabel label_13 = new JLabel("Address");
		label_13.setBounds(10, 52, 79, 14);
		panel_14.add(label_13);
		
		JLabel label_16 = new JLabel("Phone number");
		label_16.setBounds(10, 136, 93, 14);
		panel_14.add(label_16);
		
		txtCreateSupName = new JTextField();
		txtCreateSupName.setColumns(10);
		txtCreateSupName.setBounds(136, 21, 86, 20);
		panel_14.add(txtCreateSupName);
		
		txtCreateSupAddress = new JTextField();
		txtCreateSupAddress.setColumns(10);
		txtCreateSupAddress.setBounds(136, 49, 86, 20);
		panel_14.add(txtCreateSupAddress);
		
		txtCreateSupCountry = new JTextField();
		txtCreateSupCountry.setColumns(10);
		txtCreateSupCountry.setBounds(136, 77, 86, 20);
		panel_14.add(txtCreateSupCountry);
		
		txtCreateSupEmail = new JTextField();
		txtCreateSupEmail.setColumns(10);
		txtCreateSupEmail.setBounds(136, 105, 86, 20);
		panel_14.add(txtCreateSupEmail);
		
		txtCreateSupPhone = new JTextField();
		txtCreateSupPhone.setColumns(10);
		txtCreateSupPhone.setBounds(136, 133, 86, 20);
		panel_14.add(txtCreateSupPhone);
		
		final JLabel lblCreateSup = new JLabel("");
		lblCreateSup.setHorizontalAlignment(SwingConstants.CENTER);
		lblCreateSup.setBounds(10, 274, 212, 14);
		panel_14.add(lblCreateSup);
		
		JButton btnCreateSup = new JButton("Create");
		btnCreateSup.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				CtrSupplier supp = new CtrSupplier();
				
				if(txtCreateSupName.getText() != null && !txtCreateSupName.getText().isEmpty())
				{
					if(txtCreateSupAddress.getText() != null && !txtCreateSupAddress.getText().isEmpty())
					{
						if(txtCreateSupCountry.getText() != null && !txtCreateSupCountry.getText().isEmpty())
						{
							if(txtCreateSupPhone.getText() != null && !txtCreateSupPhone.getText().isEmpty())
							{
								if(txtCreateSupEmail.getText() != null && !txtCreateSupEmail.getText().isEmpty())
								{
									supp.createSupplier(txtCreateSupName.getText(), txtCreateSupAddress.getText(), txtCreateSupCountry.getText(), 
											txtCreateSupPhone.getText(), txtCreateSupEmail.getText());
									lblCreateSup.setText("Supplier Created");
								}
								else
								{
									lblCreateSup.setText("Not Created");
								}
							}
							else
							{
								lblCreateSup.setText("Not Created");
							}
						}
						else
						{
							lblCreateSup.setText("Not Created");
						}
					}
					else
					{
						lblCreateSup.setText("Not Created");
					}
				}
				else
				{
					lblCreateSup.setText("Not Created");
				}
			}
		});
		btnCreateSup.setBounds(133, 299, 89, 23);
		panel_14.add(btnCreateSup);
		
		JLabel label_9 = new JLabel("Country");
		label_9.setBounds(10, 83, 79, 14);
		panel_14.add(label_9);
		
		JLabel label_10 = new JLabel("Email");
		label_10.setBounds(10, 111, 57, 14);
		panel_14.add(label_10);
		
		JPanel panel_3 = new JPanel();
		tabbedPane.addTab("Storage", null, panel_3, null);
		panel_3.setLayout(null);
		
		JPanel panel_15 = new JPanel();
		panel_15.setLayout(null);
		panel_15.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Search for Wares", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_15.setBounds(10, 11, 232, 333);
		panel_3.add(panel_15);
		
		JLabel lblId_1 = new JLabel("ID:");
		lblId_1.setBounds(10, 22, 46, 14);
		panel_15.add(lblId_1);
		
		txtProSearch = new JTextField();
		txtProSearch.setColumns(10);
		txtProSearch.setBounds(66, 19, 156, 20);
		panel_15.add(txtProSearch);
		
		JButton btnProSearch = new JButton("Search");
		btnProSearch.setBounds(133, 50, 89, 23);
		panel_15.add(btnProSearch);
		
		List listProSearch = new List();
		listProSearch.setBounds(10, 110, 212, 154);
		panel_15.add(listProSearch);
		
		JButton button_2 = new JButton("Delete");
		button_2.setBounds(10, 270, 97, 23);
		panel_15.add(button_2);
		
		JButton button_3 = new JButton("Select");
		button_3.setBounds(125, 270, 97, 23);
		panel_15.add(button_3);
		
		JLabel label = new JLabel("Search Results");
		label.setBounds(10, 90, 124, 14);
		panel_15.add(label);
		for(int i = 0; i < 114; i++)
		{
			listProSearch.add("Test Wares " +i);
		}
		
		JPanel panel_18 = new JPanel();
		panel_18.setLayout(null);
		panel_18.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Create/Update Ware", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_18.setBounds(247, 11, 470, 333);
		panel_3.add(panel_18);
		
		JLabel label_21 = new JLabel("Name");
		label_21.setBounds(10, 24, 79, 14);
		panel_18.add(label_21);
		
		JLabel lblPurchasePrice = new JLabel("Purchase Price");
		lblPurchasePrice.setBounds(10, 52, 93, 14);
		panel_18.add(lblPurchasePrice);
		
		txtProName = new JTextField();
		txtProName.setColumns(10);
		txtProName.setBounds(136, 21, 86, 20);
		panel_18.add(txtProName);
		
		txtProPurchPrice = new JTextField();
		txtProPurchPrice.setColumns(10);
		txtProPurchPrice.setBounds(136, 49, 86, 20);
		panel_18.add(txtProPurchPrice);
		
		txtProSalesPrice = new JTextField();
		txtProSalesPrice.setColumns(10);
		txtProSalesPrice.setBounds(136, 77, 86, 20);
		panel_18.add(txtProSalesPrice);
		
		txtCountry = new JTextField();
		txtCountry.setColumns(10);
		txtCountry.setBounds(136, 108, 86, 20);
		panel_18.add(txtCountry);
		
		JButton btnProCreate = new JButton("Create");
		btnProCreate.setBounds(133, 299, 89, 23);
		panel_18.add(btnProCreate);
		
		JLabel lblSalesPrice = new JLabel("Sales Price");
		lblSalesPrice.setBounds(10, 83, 93, 14);
		panel_18.add(lblSalesPrice);
		
		JLabel label_22 = new JLabel("Minimum Stock");
		label_22.setBounds(10, 139, 93, 14);
		panel_18.add(label_22);
		
		txtMinStock = new JTextField();
		txtMinStock.setColumns(10);
		txtMinStock.setBounds(136, 136, 86, 20);
		panel_18.add(txtMinStock);
		
		JLabel label_23 = new JLabel("Country of Origin");
		label_23.setBounds(10, 111, 116, 14);
		panel_18.add(label_23);
		
		JRadioButton rdbtnClothing = new JRadioButton("Clothing");
		rdbtnClothing.setBounds(260, 20, 109, 23);
		panel_18.add(rdbtnClothing);
		
		JLabel lblSize = new JLabel("Size");
		lblSize.setBounds(270, 52, 46, 14);
		panel_18.add(lblSize);
		
		txtClothSize = new JTextField();
		txtClothSize.setBounds(367, 49, 93, 20);
		panel_18.add(txtClothSize);
		txtClothSize.setColumns(10);
		
		JLabel lblColour = new JLabel("Colour");
		lblColour.setBounds(270, 80, 46, 14);
		panel_18.add(lblColour);
		
		txtClothColor = new JTextField();
		txtClothColor.setBounds(367, 77, 93, 20);
		panel_18.add(txtClothColor);
		txtClothColor.setColumns(10);
		
		JRadioButton rdbtnEquipment = new JRadioButton("Equipment");
		rdbtnEquipment.setBounds(260, 111, 109, 23);
		panel_18.add(rdbtnEquipment);
		
		JLabel lblType = new JLabel("Type");
		lblType.setBounds(270, 139, 46, 14);
		panel_18.add(lblType);
		
		txtEquipType = new JTextField();
		txtEquipType.setBounds(367, 133, 93, 20);
		panel_18.add(txtEquipType);
		txtEquipType.setColumns(10);
		
		JLabel lblDescription = new JLabel("Description");
		lblDescription.setBounds(270, 164, 79, 14);
		panel_18.add(lblDescription);
		
		txtEquipDescription = new JTextField();
		txtEquipDescription.setBounds(367, 161, 93, 20);
		panel_18.add(txtEquipDescription);
		txtEquipDescription.setColumns(10);
		
		JRadioButton rdbtnGunReplicas = new JRadioButton("Gun replicas");
		rdbtnGunReplicas.setBounds(260, 199, 109, 23);
		panel_18.add(rdbtnGunReplicas);
		
		JLabel lblFabric = new JLabel("Fabric");
		lblFabric.setBounds(270, 232, 46, 14);
		panel_18.add(lblFabric);
		
		JLabel lblCalibre = new JLabel("Calibre");
		lblCalibre.setBounds(270, 257, 46, 14);
		panel_18.add(lblCalibre);
		
		txtGunFabric = new JTextField();
		txtGunFabric.setBounds(367, 229, 93, 20);
		panel_18.add(txtGunFabric);
		txtGunFabric.setColumns(10);
		
		txtGunCalibre = new JTextField();
		txtGunCalibre.setBounds(367, 254, 93, 20);
		panel_18.add(txtGunCalibre);
		txtGunCalibre.setColumns(10);
		
		JButton btnProUpdate = new JButton("Update");
		btnProUpdate.setBounds(10, 299, 89, 23);
		panel_18.add(btnProUpdate);
	}
}
